package com.uchedao.vehicledetection.loadstate;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import com.uchedao.vehicledetection.loadstate.base.LoadstateHttpRelativityLayout;
import com.uchedao.vehicledetection.loadstate.base.LoadstatueViewFactory;

/**
 * @author Comsys-linbinghuang
 * @ClassName: LocalStateRelativityLayout
 * @Description: 加载父类
 * @date 2014-10-10 下午4:46:29
 */
public abstract class UCheDaoLocalStateRelativityLayout extends
        LoadstateHttpRelativityLayout {

    public UCheDaoLocalStateRelativityLayout(Context context) {
        super(context);
    }

    public UCheDaoLocalStateRelativityLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public UCheDaoLocalStateRelativityLayout(Context context, AttributeSet attrs,
                                             int defStyle) {
        super(context, attrs, defStyle);

    }

    /**
     * 获取加载中的图
     *
     * @return
     */
    @Override
    public View getLoadingView() {
        if (mContentView != null) {
            return LoadstatueViewFactory.getLoadingView(getContext(),
                    mContentView);
        }
        return null;
    }

    ;

    /***
     * 获取加载失败的图
     *
     * @return
     */
    @Override
    public View getLoadFailedView() {
        if (mContentView != null) {
            return LoadstatueViewFactory.getLoadingFailed(getContext(),
                    mContentView, new OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            firstdata();
                        }
                    });
        }
        return null;
    }

    /**
     * 获取空数据视图
     *
     * @return
     */
    @Override
    public View getEmptyView(String msg) {
        if (mContentView != null) {
            return LoadstatueViewFactory.getLoadEmpty(getContext(), msg,
                    mContentView, new OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            firstdata();
                        }
                    });
        }
        return null;
    }

    @Override
    public View getEmptyView() {
        if (mContentView != null) {
            return LoadstatueViewFactory.getLoadEmpty(getContext(),
                    mContentView, new OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            firstdata();
                        }
                    });
        }
        return null;
    }

}
